package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
//        Class<String> cls1 = String.class;
//        Class<Arrays> cls2 = Arrays.class;
//        Class<Integer> cls3 = int.class;
//
//        Class<?> cls4 = Class.forName("java.lang.String");
//        Class<?> cls5 = Class.forName("java.util.ArrayList");
//        System.out.println("请输入一个类名");
//        Scanner scan = new Scanner(System.in);
//        String name = scan.nextLine();
//        Class<?> cls6 = Class.forName(name);
//        System.out.println(cls6);
        System.out.println("输入一个类名");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        Class<?> cls = Class.forName(name);
        System.out.println("获取类的完整限定名:>" + cls.getName());
        System.out.println("获取类名:>" + cls.getSimpleName());
        System.out.println("获取包:>" + cls.getPackage().getName());
//        System.out.println("获取类的方法:>"+ Arrays.toString(cls.getMethods()));
        Method[] methods = cls.getMethods();
        System.out.println("该类共有" + methods.length + "个方法");
        for (Method m : methods) {
            System.out.println(m.getName());
        }
    }
}
